package com.fz.study.project.controller;

import com.fz.study.project.entity.Result;
import com.fz.study.project.utils.AliOSSUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@Tag(name = "文件上传")
@RequestMapping("/upload")
@Slf4j
@RestController
@RequiredArgsConstructor
public class FileUploadController {
    private final AliOSSUtils aliOSSUtils;
    @Operation(summary = "上传文件")
    @PostMapping
    public Result fileUpload(MultipartFile images) throws IOException {
        String url = aliOSSUtils.upload(images);
        return Result.success(url);
    }
}
